#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <list>
#include <jsoncpp/json/json.h>
#include "../../../NetEngine_Linux/NetEngine_Release/NetEngine_Include/XyRyNet_CommHdr.h"
#include "../../../NetEngine_Linux/NetEngine_Release/NetEngine_Include/XyRyNet_Types.h"
#include "../../../NetEngine_Linux/NetEngine_Release/NetEngine_Include/XyRyNet_ProtocolHdr.h"
#include "../../../NetEngine_Linux/NetEngine_SourceCode/NetEngine_XMQCore/MQCore_XDDService/XDDS_Define.h"
#include "../../../NetEngine_Linux/NetEngine_SourceCode/NetEngine_XMQCore/MQCore_XDDService/XDDS_Error.h"

//g++ -std=gnu++11 -Wall -g TestFor_DDSPub.cpp -o TestFor_DDSPub -L ../../../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_BaseLib -L ../../../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_Core -L ../../../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_Client -L ../../../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_NetHelp -L ../../../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_XMQCore -lNetEngine_BaseLib -lNetEngine_Core -lNetClient_Socket -lNetHelp_APIHelp -lMQCore_XDDService -ljsoncpp -Wl,-rpath=../../../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_BaseLib:../../../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_Core:../../../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_Client:../../../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_NetHelp:../../../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_XMQCore,--disable-new-dtags

SOCKET m_Socket;

//TCP
int main(int argc,char **argv)
{
    if (!XDDS_CommApi_Init("192.168.1.109"))
    {
        printf("初始化失败!\n");
        return -1;
    }
    if (!XDDS_CommApi_DomainCreate(1000))
    {
        printf("XDDS_CommApi_DomainCreate 失败!\n");
        return -1;
    }
    if (!XDDS_CommApi_TopicCreate(1000,"aa"))
    {
        printf("XDDS_CommApi_TopicCreate 失败!\n");
        return -1;
    }
    printf("ok!\n");
    XNETHANDLE xhPublish;
    if (!XDDS_Publish_Create(&xhPublish,1000,"aa"))
    {
        printf("XDDS_Publish_Create 失败!\n");
        return -1;
    }

    int nTime = 0;
    while (nTime < 9999)
    {
        nTime++;
        XDDS_Publish_SendMsg(xhPublish, "hello", 5);
        Sleep(1000);
    }

    XDDS_Publish_Delete(xhPublish);
    XDDS_CommApi_TopicDelete(1000, "aa");
    XDDS_CommApi_DomainDelete(1000);
    XDDS_CommApi_Destory();
    return 0;
}
